package com.gdssoft.pdaweb;

import java.util.Calendar;
import java.util.Date;

import javax.annotation.Resource;

import org.junit.Test;

import com.gdssoft.BaseTestCase;
import com.gdssoft.pdaweb.model.CheckWorkOrder;
import com.gdssoft.pdaweb.model.PdaApplyRepair;
import com.gdssoft.pdaweb.model.RepairWorkOrder;
import com.gdssoft.pdaweb.service.EamService;

public class EamServiceTestCase extends BaseTestCase {
	@Resource
	private EamService eamService;

	
	public void testSyncRepairOrderStatus() {
		Calendar cal = Calendar.getInstance();
		cal.set(2013, 5, 10, 12, 0);
		Date sDate = cal.getTime();
		cal.set(2013, 5, 10, 18, 0);
		Date eDate = cal.getTime();
		/*
		//测试转单 max2PDADelegate.returnWO
		RepairWorkOrder rwo1 = new RepairWorkOrder();
		rwo1.setStatus("2");
		rwo1.setAppointPeople("MAXADMIN");
		rwo1.setAssignmentId(4L);
		System.out.println("----- " + eamService.syncRepairOrderStatus(rwo1));
		
		rwo1.setAssignmentId(102L);
		System.out.println("----- " + eamService.syncRepairOrderStatus(rwo1));
		
		rwo1.setAssignmentId(265L);
		System.out.println("----- " + eamService.syncRepairOrderStatus(rwo1));
		*/
		
		//测试完成维修工单 max2PDADelegate.changeStatusbyWOId
		RepairWorkOrder rwo2 = new RepairWorkOrder();
		rwo2.setStatus("9");
		rwo2.setAppointPeople("MAXADMIN");
		rwo2.setWoNum("1008");
		rwo2.setSiteID("BEDFORD");
		//rwo2.setAssignmentId(37L);
		rwo2.setBeginTime(sDate);
		rwo2.setEndTime(eDate);
		System.out.println("----- " + eamService.syncRepairOrderStatus(rwo2));

		//rwo2.setAssignmentId(75L);
		//System.out.println("----- " + eamService.syncRepairOrderStatus(rwo2));
		
	}
	
	
	public void testSyncCheckOrderStatus() {
		Calendar cal = Calendar.getInstance();
		cal.set(2013, 5, 10, 12, 0);
		Date sDate = cal.getTime();
		cal.set(2013, 5, 10, 18, 0);
		Date eDate = cal.getTime();
		//测试完成巡检工单
		CheckWorkOrder cwo = new CheckWorkOrder();
		cwo.setStatus("9");
		cwo.setAppointPeople("MAXADMIN");
		cwo.setAssignmentID(139L);
		cwo.setBeginTime(sDate);
		cwo.setEndTime(eDate);
		System.out.println("----- " + eamService.syncCheckOrderStatus(cwo));
	}
	
	@Test
	public void testSyncApplyRepair() {
		//测试生成现场维修工单
		/*
		Max2PDAService max2PDAService = new Max2PDAService();
		Max2PDADelegate max2PDADelegate = max2PDAService.getMax2PDAPort();
		max2PDADelegate.createWO("TYJADMIN", "bbb", "ccc", "ddd", 1, 0);
		*/
		PdaApplyRepair ar1 = new PdaApplyRepair();
		ar1.setRecordeId("MAXADMIN");
		ar1.setBarCode("11300");
		ar1.setLocatedId("BR300");
		ar1.setRemark("PDA产生现场工单测试--资产位置");
		ar1.setReason("");
		ar1.setWorkStatus("0");
		System.out.println("现场工单 ---> " + eamService.createApplyRepair(ar1));

		//ar1.setBarCode("");
		//ar1.setLocatedId("BR300");
		//ar1.setRemark("PDA产生现场工单测试--位置");
		//System.out.println("现场工单2 ---> " + eamService.createApplyRepair(ar1));

		//ar1.setBarCode("11300");
		//ar1.setLocatedId("BR300");
		//ar1.setRemark("PDA产生现场工单测试--资产位置");
		//System.out.println("现场工单3 ---> " + eamService.createApplyRepair(ar1));
		
		//测试生成非现场维修工单
		PdaApplyRepair ar2 = new PdaApplyRepair();
		ar2.setRecordeId("MAXADMIN");
		ar2.setBarCode("11300");
		ar2.setLocatedId("BR300");
		ar2.setRemark("PDA产生现场工单测试--资产位置");
		ar2.setReason("坏掉了");
		ar2.setWorkStatus("1");
		System.out.println("非现场工单 ---> " + eamService.createApplyRepair(ar2));

		//ar2.setBarCode("");
		//ar2.setLocatedId("BR300");
		//ar2.setRemark("PDA产生现场工单测试--位置");
		//System.out.println("非现场工单2 ---> " + eamService.createApplyRepair(ar2));

		//ar2.setBarCode("11300");
		//ar2.setLocatedId("BR300");
		//ar2.setRemark("PDA产生现场工单测试--资产位置");
		//System.out.println("非现场工单3 ---> " + eamService.createApplyRepair(ar2));
	}
}
		
